// 历史数据一览
import { ref, onMounted, reactive, defineComponent } from "vue";
import { dxget, qurl } from "../../util/index";
export default defineComponent({
  props: {
    code: {
      type: String,
    },
    maxHeight: {
      type: Number,
      default: 660,
    },
  },
  setup(props) {
    let tableData = ref([]);
    const paginationReactive = reactive({
      page: 1,
      pageCount: 1,
      pageSize: 15,
    });
    let columns = [
      {
        title: "交易日期",
        key: "time",
        align: "center",
      },
      {
        title: "收盘价",
        key: "je",
        align: "center",
      },
      {
        title: "涨跌幅(%)",
        key: "zf",
        align: "center",
      },
      {
        title: "净流向",
        key: "zjlx",
        align: "center",
      },
    ];
    const initData = async () => {
      let kjjhe: any = await dxget("dc/getDBHistoryData", {
        code: props.code,
      });
      tableData.value = kjjhe.data;
    };

    initData();
    const rowClassName = (row, index) => {
      if (row.zf >= 0) {
        return "red";
      }
      return "ls";
    };
    return () => (
      <>
        <n-card title="历史数据一览">
          <div class="table-tbody-s">
            <n-data-table
              size="small"
              row-class-name={rowClassName}
              max-height={props.maxHeight}
              columns={columns}
              data={tableData.value}
              single-line={false}
            />
          </div>
        </n-card>
      </>
    );
  },
});
